﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Text;
using System.Web;
using Volo.Abp.AspNetCore.Mvc;

namespace Xms.Abp.AspNetCore.Mvc;

//[Authorize]
[Controller]
public abstract class XmsController : AbpController
{
    protected TService LazyInject<TService>()
    {
        return LazyServiceProvider.LazyGetRequiredService<TService>();
    }

    [Obsolete("Use LazyInject method.")]
    protected TService Inject<TService>()
    {
        return ServiceProvider.GetRequiredService<TService>();
    }
}
public abstract class XmsController<TService> : XmsController
{
    protected TService CurrentService => LazyInject<TService>();

    protected virtual FileResult ExportAsync(byte[] bytes, string fileName)
    {
        return File(bytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName);
    }
}

